<template>
  <div class="main">
    <!-- <div class="tabContannier">
      <el-tabs type="border-card">
        <el-tab-pane label="监测报告"></el-tab-pane>
        <el-tab-pane label="广告效果"></el-tab-pane>
      </el-tabs>
    </div> -->
    <div class="mainContanier">
      <el-table
          :data="tableData"
          :cell-style="$rowstyle"
          :header-cell-style="$headerstyle"
          style="width: 100%"
        >
          <el-table-column type="index" label="序号"  ></el-table-column>
          <el-table-column prop="get_files.file_name" label="文件" ></el-table-column>
          <el-table-column prop="get_admin_info.name" label="上传人" ></el-table-column>

          <el-table-column prop="created_at" label="上传时间" >
            <template slot-scope="scope">
             <span>{{transDate(scope.row.created_at)}}</span>
            </template>

          </el-table-column>
          <!-- <el-table-column prop="city" label="回款记录" ></el-table-column> -->
          <el-table-column label="操作" width="150">
            <template slot-scope="scope">
              <el-button @click="handleDelte(scope.row)" type="text" size="small">删除</el-button>
              <a :href="scope.row.get_files.file_path" :download='scope.row.get_files.file_name' style="color:#1682e6;font-size:12px;"   v-if="scope.row.get_files">下载</a>
              <!-- <el-button type="text" @click="handleLog(scope.row)" size="small">日志</el-button> -->
            </template>
          </el-table-column>
        </el-table>
    </div>
  </div>
</template>

<script>
import VDistpicker from "v-distpicker";
import {playResult,deleteResult} from '../../../api/Salesman.js'
import moment from 'moment'
export default {
  props:['id'],
  data() {
    return {
        tableData:[]
    };
  },
  methods:{
     transDate(time){
      return moment.unix(time).format("YYYY-MM-DD")
    },
    getResult(){
      playResult(this.id).then(res=>{
        if (res.code == 200) {
          this.tableData = res.data
        }else{
          this.$message.error('获取播放结果失败')
        }
      })
    },
    handleDownload(data){
      console.log(window.location.origin + data.get_files.file_path)
      window.open(window.location.origin + data.get_files.file_path)
    },
    handleDelte(data){
      deleteResult(data.id).then(res=>{
        if (res.code == 200) {
          this.$message.success('删除成功')
          this.getResult()
        }else{
          this.$message.error('删除失败')
        }
      })
    }
  },
  mounted(){
    this.getResult()
  }
};
</script>

<style scoped>
.main {
  width: 100%;
  height: 100%;
}
</style>
